import 'package:flutter/material.dart';

class BaseMaterialInfo extends StatelessWidget {
  final Widget imgwid;
  final Map<String,dynamic> options;
  final Map<String,dynamic> data;
  BaseMaterialInfo({Key key, this.imgwid,this.options,this.data})
      : assert(imgwid != null),
        assert(options != null),
        assert(data != null),
        super(key: key);

  @override
  Widget build(BuildContext context) {
    List<String> keys=options.keys.toList();
    List<dynamic> vals=options.values.toList();
    List<Widget> childWidgets = List();
    if(keys.length == 0){
      childWidgets.add(Center(
          child: Text(
            "暂无数据",
            overflow: TextOverflow.ellipsis,
          ))
      );
    }else{
      for(int i=0;i<keys.length;i++){
        childWidgets.add(Container(
            padding: EdgeInsets.all(4),
            child: Text(
              "${vals[i]}:${data[keys[i]]??"暂无"}",
            )
          )
        );
      }
    }
    // TODO: implement build
    return Container(
        padding: EdgeInsets.all(15),
        alignment: Alignment.center,
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Container(
              width: 120,
              height: 120,
              margin: EdgeInsets.only(right: 10),
              child: imgwid,
            ),
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: childWidgets
              ),
            )
          ],
        ));
  }
}
